<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	template="/WEB-INF/template.xhtml">
	<ui:define name="title">Key Store: #{hsmProxyKeyStore.selectedKeyStore.name}</ui:define>
	<ui:define name="body">
		<h:panelGrid columns="2">
			<h:outputText value="Key store type:" />
			<h:outputText
				value="#{hsmProxyKeyStore.selectedKeyStore.keyStoreType}" />

			<h:outputText value="Path:" />
			<h:outputText value="#{hsmProxyKeyStore.selectedKeyStore.path}" />

			<h:outputText value="Slot list index:"
				rendered="#{hsmProxyKeyStore.selectedKeyStore.keyStoreType == 'PKCS11'}" />
			<h:outputText
				value="#{hsmProxyKeyStore.selectedKeyStore.slotListIndex}"
				rendered="#{hsmProxyKeyStore.selectedKeyStore.keyStoreType == 'PKCS11'}" />

			<h:outputText value="Key store state:" />
			<h:outputText
				value="#{hsmProxyKeyStore.selectedKeyStore.keyStoreState}" />
		</h:panelGrid>
		<h:form id="mainForm">
			<p:dataTable id="table" var="row"
				value="#{hsmProxyKeyStore.selectedKeyStoreAliases}" paginator="true"
				rows="10">
				<f:facet name="header">
					Keys
				</f:facet>
				<p:column>
					<f:facet name="header">Key alias</f:facet>
					<h:outputText value="#{row}" />
				</p:column>
				<p:column>
					<f:facet name="header">Actions</f:facet>
					<p:commandLink id="viewButton" styleClass="ui-icon ui-icon-search"
						style="display:inline-block;"
						actionListener="#{hsmProxyKeyStore.selectKeyStoreAlias}"
						oncomplete="viewDialog.show();" update=":messages,:viewForm">
						<f:attribute name="selectedKeyStoreAlias" value="#{row}" />
					</p:commandLink>
					<p:tooltip for="viewButton" value="View certificate..." />
				</p:column>
			</p:dataTable>

			<br />

			<p:dataTable id="usedByTable" var="row"
				value="#{hsmProxyKeyStore.selectedKeyStoreApplications}"
				paginator="true" rows="10">
				<f:facet name="header">
					Used by applications
				</f:facet>
				<p:column>
					<f:facet name="header">Name</f:facet>
					<h:outputText value="#{row.name}" />
				</p:column>
			</p:dataTable>
		</h:form>

		<h:form>
			<p:commandButton value="Back" action="#{hsmProxyKeyStore.back}"
				ajax="false" />
		</h:form>

		<p:dialog widgetVar="viewDialog" header="View Certificate"
			modal="true">
			<h:form id="viewForm">
				<p:carousel value="#{hsmProxyKeyStore.certificates}" var="cert"
					numVisible="1">
					<h:panelGrid columns="2">
						<h:outputText value="Subject:" />
						<h:outputText value="#{cert.subject}" />

						<h:outputText value="Issuer:" />
						<h:outputText value="#{cert.issuer}" />

						<h:outputText value="Serial number:" />
						<h:outputText value="#{cert.serialNumber}" />

						<h:outputText value="Not before:" />
						<h:outputText value="#{cert.notBefore}">
							<f:convertDateTime type="both" timeStyle="full" />
						</h:outputText>

						<h:outputText value="Not after:" />
						<h:outputText value="#{cert.notAfter}">
							<f:convertDateTime type="both" timeStyle="full" />
						</h:outputText>

						<h:outputText value="Days left:" />
						<h:outputText value="#{cert.daysLeft}" />
					</h:panelGrid>
				</p:carousel>
			</h:form>
		</p:dialog>

	</ui:define>
</ui:composition>